#include <GL/gl.h>
#include <iostream>
#include <sstream>
#include <utility>
#include <vector>
using std::cout;
using std::endl;

#include "loader.h"
#include "object3d.h"
#include "base/error.h"
#include "base/tcvertex.h"
#include "light/lighting.h"
#include "camera.h"

int main(int argc, char* argv[])
{
    loader<vertex<GLfloat>, cvertex<GLfloat,GLfloat>, GLfloat, GLfloat, int> l;
    object3d<vertex<GLfloat>, cvertex<GLfloat,GLfloat>, GLfloat, GLfloat, int> o(-1e10,1e10);
    error e;
    std::string name = "cube.tgt";
    
    
    if(argc>1) {
        std::istringstream s(argv[1]);
        std::string str;
        s >> str;
        if(s.fail()==false && str.length()>0)
            name = str;
    }
    e = l.load_tgt(name.c_str(), o);
    cout << "code " << e.get_code() << endl;
    cout <<  e.get_desc() << ", line " << e.get_linenr() << endl;

    cout<<"werteksow "<<o.vcount<<endl;
    cout<<"zas kolorowych "<<o.cvcount<<endl;
    cout<<"materialow "<<o.mcount<<endl;
    cout<<"trojkatow "<<o.tcount<<endl;
    cout<<"i kolorowych "<<o.ctcount<<endl;
    
    
    cout<<o.xbord[0]<<"  "<<o.xbord[1]<<endl;
    cout<<o.ybord[0]<<"  "<<o.ybord[1]<<endl;
    cout<<o.zbord[0]<<"  "<<o.zbord[1]<<endl;

    cout<<o.verts.size()<<endl;
    cout<<o.verts.capacity()<<endl;
    cout<<o.cverts.size()<<endl;
    cout<<o.cverts.capacity()<<endl;
    cout<<o.tris.size()<<endl;
    cout<<o.tris.capacity()<<endl;
    cout<<o.ctris.size()<<endl;
    cout<<o.ctris.capacity()<<endl;
    cout<<o.mats.size()<<endl;
    cout<<o.mats.capacity()<<endl;
}

